<template>
  <view class="box">
    <!-- -->
    <view v-for="(item, index) in list" :key="index" class="dai">
      <view class="dai_con">
        {{ JSON.parse(item.message).content }}
        <text @click="detail(item)" class="title"
          >{{
            JSON.parse(item.message).content.includes("处理")
              ? "去处理"
              : "去查看"
          }}>></text
        >
      </view>
    </view>
  </view>
</template>

<script>
import { messageList, messageUpdate } from "@/api";
export default {
  name: "",

  data() {
    return {
      list: [],
    };
  },
  async onShow(options) {
    const res = await messageList();
    this.list = res.data.records;
  },

  mounted() {},

  methods: {
    async detail(item) {
      //修改状态
        const res = await messageUpdate({
          id: item.id,
        });
      //跳转详情页
      const content = JSON.parse(item.message).content;
      const type = JSON.parse(item.message).isDeal ? "0" : "";
        if (res.code == 200) {
      if (content.includes("用车")) {
        if (content.includes("查看")) {
          //派车记录
          uni.navigateTo({
          url: `/pages/vehiclemanagement/sendcar?row=${JSON.stringify(
            item
          )}`,
        });
        }else{
  //用车申请详情
        uni.navigateTo({
          url: `/pages/cardetail/index?row=${JSON.stringify(
            item
          )}&type=${type}`,
        });
        }
      
      } else if (content.includes("发文")) {
        //发文申请详情
        uni.navigateTo({
          url: `/pages/cardetail/dispatchdetail?row=${JSON.stringify(
            item
          )}&type=${type}`,
        });
      } else if (content.includes("用章")) {
        // 用章申请详情
        uni.navigateTo({
          url: `/pages/cardetail/chaptersdetail?row=${JSON.stringify(
            item
          )}&type=${type}`,
        });
      }
        }
    },
  },
};
</script>
<style scoped lang="scss">
page {
  background-color: #f2f2f2;
}
.box {
  min-height: 100vh;
  background-color: #f2f2f2;
}
.dai {
  width: 94%;
  height: 100px;
  border-radius: 10px;
  margin: 4% auto;
  background-color: #fff;
  .dai_con {
    width: 90%;
    padding-top: 30px;
    margin: 0 auto;
    .title {
      color: #2c53f2;
    }
  }
}
</style>